package com.woniuxy.amusementparkos.service.lsy.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.woniuxy.amusementparkos.dao.lsy.ConsumerTypeDao;
import com.woniuxy.amusementparkos.entity.lsy.ConsumerType;
import com.woniuxy.amusementparkos.exception.ObjectNotExistException;
import com.woniuxy.amusementparkos.service.lsy.ConsumerTypeService;

/**
* @author Muzi
* 消费类型管理服务实现类
* 2020年4月26日下午12:12:12
*/
@Service
public class ConsumerTypeServiceImpl implements ConsumerTypeService {
	//注入dao
	@Autowired
	ConsumerTypeDao consumerTypeDao;
	
	@Override
	public List<ConsumerType> listAllConsumerTypes() {
		return consumerTypeDao.listAllConsumerType();
	}

	@Override
	public void insertOneConsumerType(ConsumerType consumerType) {
		consumerTypeDao.insertConsumerType(consumerType);
	}

	@Override
	public void deleteOneConsumerType(Integer type_id) throws RuntimeException {
		Integer rows = consumerTypeDao.deleteConsumerType(type_id);
		if(rows == 0) {
			throw new ObjectNotExistException("删除目标不存在");
		}
	}

	@Override
	public void updateOnrConsumerType(ConsumerType consumerType) throws RuntimeException {
		Integer rows = consumerTypeDao.updateConsumerType(consumerType);
		if(rows == 0) {
			throw new ObjectNotExistException("更新不成功，目标不存在");
		}
	}

}
